/**
 * 导出Excel
 * get
 */
import axios from 'axios'
export const download_excel = (_url, _filename) => {
    axios({
        method: 'get',
        url: process.env.VUE_APP_BASE_API + _url,
        responseType: 'blob',
        headers: {
            token: JSON.parse(sessionStorage.getItem('USERINFO')).token
        }
    })
        .then(res => {
            if (!res) return
            const objectUrl = URL.createObjectURL(res.data)
            const a = document.createElement('a')
            document.body.appendChild(a)
            a.href = objectUrl
            const filenames = decodeURIComponent(res.headers['filename'])
            a.download = filenames
            a.click()
            window.URL.revokeObjectURL(objectUrl)
        })
        .catch(err => {
            console.log(err)
        })
}
